-- In this lesson we will break the while loop condition to stop the coin from Rotating.  
-- I will use the coin in the last video.  
-- If you need a copy of the coin, get it here: https://www.roblox.com/library/10832103835/Coin

--- Rotate
local coin = script.Parent
local isRotate = script.Parent.IsRotate

local function rotate()
	while isRotate.Value do
		coin.Orientation = coin.Orientation + Vector3.new(0, 10, 0)
		wait()
	end
end

rotate()



-- StopCoin
local coin = script.Parent
local isRotate = script.Parent.IsRotate

local function onCollect(otherPart)
	local hum = otherPart.Parent:FindFirstChild("Humanoid")
	
	if hum then 
		isRotate.Value = false
	end
end

coin.Touched:Connect(onCollect)